home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_quik.lha / quickdraw / src / calc_calls.c next >
Encoding:
C/C++ Source or Header  |  1989-12-09  |  2.9 KB  |  133 lines

  1. /*------------------------------- calc_calls.c -------------------------------*/
  2. /* Copyright 1989 Brown University -- Jeffrey Vogel                           */
  3. /*----------------------------------------------------------------------------*/
  4.  
  5. /*--------------------------------- Includes ---------------------------------*/
  6. /*----------------------------------------------------------------------------*/
  7.  
  8. #include "qd_local.h"
  9.  
  10. /*---------------------------------- SetPt -----------------------------------*/
  11. /*----------------------------------------------------------------------------*/
  12.  
  13. void
  14. SetPt(point, x, y)
  15. Point *point;
  16. int   x, y;
  17. {
  18.    /*** error check ***/
  19.    if (!QDrunning) {
  20.       QDerror("ERROR SetPt: QuickDraw not initialized.");
  21.       return;
  22.    }
  23.     
  24.    point->x = x;
  25.    point->y = y;
  26. }
  27.    
  28.  
  29.  
  30.  
  31. /*--------------------------------- SetRect ----------------------------------*/
  32. /*----------------------------------------------------------------------------*/
  33.  
  34. void
  35. SetRect(rect, left, top, right, bottom)
  36. Rect   *rect;
  37. int    left, top, right, bottom;
  38. {
  39.    /*** error check ***/
  40.    if (!QDrunning) {
  41.       QDerror("ERROR SetRect: QuickDraw not initialized.");
  42.       return;
  43.    }
  44.    if (left > right) {
  45.       QDerror("ERROR SetRect: Invalid rectangle specifications.");
  46.       return;
  47.    }
  48.    if (top > bottom) {
  49.       QDerror("ERROR SetRect: Invalid rectangle specifications.");
  50.       return;
  51.    }
  52.  
  53.    rect->left    = left;
  54.    rect->top     = top;
  55.    rect->right   = right;
  56.    rect->bottom  = bottom;
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. /*-------------------------------- OffsetRect --------------------------------*/
  68. /*----------------------------------------------------------------------------*/
  69.  
  70. void
  71. OffsetRect(rect, dh, dv)
  72. Rect  *rect;
  73. int   dh, dv;
  74. {
  75.    /*** error check ***/
  76.    if (!QDrunning) {
  77.       QDerror("ERROR OffsetRect: QuickDraw not initialized.");
  78.       return;
  79.    }
  80.  
  81.    rect->left   += dh;
  82.    rect->right  += dh;
  83.    rect->top    += dv;
  84.    rect->bottom += dv;
  85. }
  86.  
  87. /*-------------------------------- InsetRect ---------------------------------*/
  88. /*----------------------------------------------------------------------------*/
  89.  
  90. void
  91. InsetRect(rect, dh, dv)
  92. Rect  *rect;
  93. int   dh, dv;
  94. {
  95.    /*** error check ***/
  96.    if (!QDrunning) {
  97.       QDerror("ERROR InsetRect: QuickDraw not initialized.");
  98.       return;
  99.    }
  100.  
  101.    rect->top      += dv;
  102.    rect->bottom   -= dv;
  103.    rect->left     += dh;
  104.    rect->right    -= dh;
  105. }
  106.  
  107. /*--------------------------------- PtInRect ---------------------------------*/
  108. /*----------------------------------------------------------------------------*/
  109.  
  110. Boolean
  111. PtInRect(point, rect)
  112. Point  point;
  113. Rect   rect;
  114. {
  115.    /*** error check ***/
  116.    if (!QDrunning) {
  117.       QDerror("ERROR PtInRect: QuickDraw not initialized.");
  118.       return;
  119.    }
  120.  
  121.    if (point.x < rect.left) return FALSE;
  122.    if (point.x > rect.right) return FALSE;
  123.    if (point.y < rect.top) return FALSE;
  124.    if (point.y > rect.bottom) return FALSE;
  125.  
  126.    return TRUE;
  127. }
  128.  
  129.  
  130.  
  131.  
  132.  
  133.